﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class ReplyMessageDAO:BaseService
    {
        /// <summary>
        /// 查询回复个数
        /// </summary>
        /// <param name="mesId"></param>
        /// <returns></returns>
        public int GetRepluCount(int mesId)
        {
            string hql = "select count(*) from ReplyMessage where messId="+mesId;
            return Convert.ToInt32(DBHelper.ExecuteHQL(hql).UniqueResult());
        }

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="mesId"></param>
        /// <returns></returns>
        public IList<ReplyMessage> FindByMesId(int mesId)
        {
            string hql = "from ReplyMessage where messId="+mesId;
            return FindList<ReplyMessage>(hql, null, null, null);
        }
        /// <summary>
        /// 查询总条数
        /// </summary>
        /// <returns></returns>
        public int GetCount(int mesId)
        {
            string hql = "select count(*) from ReplyMessage where messId="+mesId;
            return Convert.ToInt32(GetValue(hql));
        }
        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="CurrentIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public IList<ReplyMessage> FindByMesId(int mesId, int CurrentIndex, int pageSize)
        {

            string hql = "from ReplyMessage where 1=1 ";
            if (mesId>0)
            {
                hql += " and messId="+mesId;
            }
            hql += "  order by Id desc";
            return FindList<ReplyMessage>(hql, null, (CurrentIndex - 1) * pageSize, pageSize);
        }
    }
}
